package com.itheima.security;

import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Component;
import org.springframework.util.AntPathMatcher;

import javax.servlet.http.HttpServletRequest;

@Component("authService")
public class AuthServiceImpl implements AuthService{


    private AntPathMatcher antPathMatcher = new AntPathMatcher();

    @Override
    public boolean hasPermission(HttpServletRequest request, Authentication authentication) {
        String uri = request.getRequestURI();
        System.out.println("uri:" + uri);
        //   /sayHello/* /sayHello/robin
        if(antPathMatcher.match("/sayHello/*", uri)){
            return true;
        }else{
            return false;
        }
    }
}
